/**
 * 
 */
package com.seraph.zys.web.pccexport;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.seraph.bi.suite.support.domain.pagination.ExtPagingGridBean;
import com.seraph.bi.suite.support.security.BaseUser;
import com.seraph.bi.suite.support.security.LoginUtil;
import com.seraph.bi.suite.support.web.base.BaseCondition;
import com.seraph.bi.suite.support.web.base.BaseHelper;
import com.seraph.bi.suite.support.web.json.JsonPagingProviderController;
import com.seraph.zys.dao.PrAlFundsArrangementDAO;
import com.seraph.zys.dao.domain.PrAlFundsArrangementExample;

/**
 * 类说明:<br>
 * 创建时间: <br>
 * @author <br>
 * @email: <br>
 */
@Controller
@RequestMapping("/prAlFundsArrangementListProvider.do")
public class PrAlFundsArrangementListProviderController extends JsonPagingProviderController{

	@Autowired
	private PrAlFundsArrangementDAO prAlFundsArrangementDAO;
	
	public void setPrAlFundsArrangementDAO(PrAlFundsArrangementDAO prAlFundsArrangementDAO) {
		this.prAlFundsArrangementDAO = prAlFundsArrangementDAO;
	}

	@RequestMapping(method = { RequestMethod.GET })
	protected ExtPagingGridBean handleJsonRequest(HttpServletRequest request,
			HttpServletResponse response) {
			
		try {	
			//String orderByClause = request.getParameter("orderBy");
			String condition = request.getParameter("condition");
			List<BaseCondition> filters = BaseHelper.createFilter(condition);
			BaseUser user = (BaseUser) LoginUtil.getUser();
			String org_Code = user.getOrgCode();			

			PrAlFundsArrangementExample example = new PrAlFundsArrangementExample();
			example = (PrAlFundsArrangementExample) BaseHelper.createExample(PrAlFundsArrangementExample.class, filters);

			if(example.getFromArea()==null||"".equals(example.getFromArea())){
				example.setFromArea(org_Code);
				example.setFromArea_Indicator(PrAlFundsArrangementExample.EXAMPLE_EQUALS);			
			}

			//totalCount=prAlFundsArrangementDAO.selectCountByExample(example);
			
			//PageBox pageBox = (PageBox) prAlFundsArrangementDAO.selectByExampleWithPaging(example, pageSize, pageNum,orderByClause);
			List<?> dataList = prAlFundsArrangementDAO.selectByExample(example, "sort_id");

			ExtPagingGridBean bean = new ExtPagingGridBean();
			bean.setDataList(dataList);
			//bean.setTotalCount(totalCount);
			
            return bean;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}